<template>
	<view class="content">

		<view class="user_from qcfd" style="background-color: #FFFFFF;">
			<text class="fl impot_font">发单店铺 :</text><input placeholder-style="font-size:28rpx;color:#ACACAC;"
				v-model="deliver_name" class="uni-input fl" placeholder="请填写发单店铺信息" />
		</view>
		<view class="user_from qcfd" style="background-color: #FFFFFF;">
			<text class="fl impot_font">手机 :</text><input   type="number" placeholder-style="font-size:28rpx;color:#ACACAC;" @blur="yzsjg"
				v-model="deliver_phone" class="uni-input fl" placeholder="请填写发单人手机号码" />
		</view>
		<view class="user_from qcfd" style="background-color: #FFFFFF;">
			<text class="fl impot_font">地址 :</text><input placeholder-style="font-size:28rpx;color:#ACACAC;"
				v-model="deliver_adress" class="uni-input fl" placeholder="请输入发单地址（例如：冻品区1栋1号）" />
		</view>
		<view class="deliver_info">
			<button @click="submitDeliver" type="default"  :disabled="jyan" :loading="jyan">确定</button>
		</view>


	</view>
</template>

<script>
	import requestUrl from '@/index.js'
	export default {
		data() {
			return {
				deliver_name: '',
				deliver_phone: '',
				deliver_adress:'',
				deliver_:{},
				jyan:false
			}
		},
		onShow() {
		  if(uni.getStorageSync("token")){
			  this.getDeliver()
		}
		//  else if(uni.getStorageSync("txfhr")){
			
		// }
		},
		
		
		
		
		
		methods: {
			async yzsjg(evt){
				let oldphone = evt.target.value
				let phonereg=11&&/^((13|14|15|16|17|18|19)[0-9]{1}\d{8})$/
				if(! phonereg.test(oldphone)){
					return this.$api.msg('请填写正确的手机号')
				}
				},
			async submitDeliver() {
				 if(!uni.getStorageSync("token")){
					this.deliver_.deliver_adress=this.deliver_adress
					this.deliver_.deliver_name=this.deliver_name
					this.deliver_.deliver_phone=this.deliver_phone
					uni.setStorageSync('txfhrs',this.deliver_)
				return	uni.showModal({
					    title: '提示',
					    content: '您未登录,是否跳转到登录页',
					    success:await function (res) {
					        if (res.confirm) {
					            uni.switchTab({
					            	url:'../mine/mine'
					            })
					        } else if (res.cancel) {
					           
					        }
					    }
					});
				}
				let phonereg=11&&/^((13|14|15|16|17|18|19)[0-9]{1}\d{8})$/
				if(this.deliver_adress==''||this.deliver_name==''||this.deliver_phone==''){
					return this.$api.msg('请填写完整信息')
				}else if(! phonereg.test(this.deliver_phone)){
					
					return this.$api.msg('请填写正确的手机号')
				}
				this.jyan=true
				
				try{
					var resz = await this.$request.put(this.$requestUrl.FDRINFO_URL, {
						data: {
							name: this.deliver_name,
							phone:this.deliver_phone,
							address:this.deliver_adress,
							
						}
					});
				}catch(e){
					this.$api.msg('网络错误，请重试')
					return this.jyan=false
				}
				if (resz){
					uni.switchTab({
						url:'../index/index'
					})
					this.jyan=false
				}else{
					this.$api.msg(resz|| '系统繁忙，请稍后重试')
					this.jyan=false
				}
					
			},
			async	getDeliver(){
				let res = await this.$request.get(this.$requestUrl.USERINFO_URL, {
					data: {
						
					}
				});
				if(res.extra){
					this.deliver_name=JSON.parse(res.extra).name
					this.deliver_adress=JSON.parse(res.extra).address
					this.deliver_phone=JSON.parse(res.extra).phone
				 }
				 // else{
				// 	if(uni.getStorageSync("txfhrs")){
				// 		this.deliver_name=uni.getStorageSync('txfhrs').deliver_name
				// 		this.deliver_adress=uni.getStorageSync('txfhrs').deliver_adress
				// 		this.deliver_phone=uni.getStorageSync('txfhrs').deliver_phone
				// 	}
				// }
				
				this.$api.msg(res || '系统繁忙，请稍后重试')
			},
			}
		
	// methods: {
	// 		async yzsjg(evt){
	// 			let oldphone = evt.target.value
	// 			let phonereg=11&&/^((13|14|15|16|17|18|19)[0-9]{1}\d{8})$/
	// 			if(! phonereg.test(oldphone)){
	// 				return this.$api.msg('请填写正确的手机号')
	// 			}
	// 			},
	// 		 submitDeliver() {
	// 			 this.deliver_.deliver_adress=this.deliver_adress
	// 			 this.deliver_.deliver_name=this.deliver_name
	// 			 this.deliver_.deliver_phone=this.deliver_phone
	// 			let phonereg=11&&/^((13|14|15|16|17|18|19)[0-9]{1}\d{8})$/
	// 			if(this.deliver_adress==''||this.deliver_name==''||this.deliver_phone==''){
	// 				return this.$api.msg('请填写完整信息')
	// 			}else if(! phonereg.test(this.deliver_phone)){
					
	// 				return this.$api.msg('请填写正确的手机号')
	// 			}
	// 			uni.setStorageSync('txfhrs',this.deliver_)
				
	// 			uni.switchTab({
	// 				url:'../index/index'
	// 			})
				
	// 		},
	// 			getDeliver(){
	// 				this.deliver_name=uni.getStorageSync('txfhrs').deliver_name
	// 				this.deliver_adress=uni.getStorageSync('txfhrs').deliver_adress
	// 				this.deliver_phone=uni.getStorageSync('txfhrs').deliver_phone
	// 		},
	
	// 	}
	}
</script>

<style>
	.content {
		position: relative;
		height: 100vh;
	}

	.user_from {
		padding: 26rpx;
		border-radius: 8rpx;
		margin: 24rpx 22rpx;
	}


	.impot_font {
		font-size: 28rpx;
		font-weight: 500;
	}

	.deliver_info {
		width: 100%;
		padding: 10rpx 0;
		position: fixed;
		bottom: 0rpx;
		background-color: #FFFFFF;
		padding-bottom: 30rpx;
	}

	.deliver_info button {
		width: 702rpx;
		height: 80rpx;
		line-height: 80rpx;
		margin: 0 auto;
		background-color: #FF690D;
		border-radius: 40rpx !important;
		color: #FFFFFF;
	}
	 input{
		 margin-left: 30rpx;
		 width: 450rpx;
		 overflow: hidden;
		 	white-space: nowrap;
		 		text-overflow: ellipsis;
	 }
</style>

 
 
 